#include <iostream>
class Person
{
private:
    int m_age;
    int *m_hetght;

public:
    Person(int age, const int &height);
    Person(const Person &p);
    ~Person();
    void print();

    static int times;
};
int Person::times = 5;

Person::Person(int age, const int &height)
{
    m_age = age;
    m_hetght = new int(height);
}

Person::Person(const Person &p)
{
    m_age = p.m_age;
    /*浅拷贝*/
    // m_hetght = p.m_hetght;

    /*深拷贝*/
    m_hetght = new int(*p.m_hetght);
}
Person::~Person()
{
    if (m_hetght != NULL)
    {
        delete m_hetght;
        m_hetght = NULL;
    }
}
void Person::print()
{
    std::cout << "age=" << m_age << std::endl;
    std::cout << "height=" << *m_hetght << std::endl;
}
int main()
{
    Person p1(18, 160);
    p1.print();
    Person p2(p1);
    p2.print();

    /*通过类名访问*/
    std::cout << "times=" << Person::times << std::endl;
    Person::times = 99;
    std::cout << "times=" << Person::times << std::endl;
    p1.times = 50;
    /*通过对象访问*/
    std::cout << "times=" << p1.times << std::endl;
}